package cn.deepxi.base.service.impl;

import cn.deepxi.base.mapper.BaseMapper;
import cn.deepxi.base.query.BasicQuery;
import cn.deepxi.base.service.IBaseService;
import cn.deepxi.utils.QueryResult;
import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

public class BaseServiceImpl<T> implements IBaseService<T> {
    @Autowired
    private BaseMapper<T> baseMapper;

    @Override
    public void add(T t) {
        baseMapper.add(t);
    }

    @Override
    public void del(Long id) {
        baseMapper.del(id);
    }

    @Override
    public void upt(T t) {
        baseMapper.upt(t);
    }

    @Override
    public T findById(Long id) {
        return baseMapper.findById(id);
    }

    @Override
    public List<T> findAll() {
        return baseMapper.findAll();
    }

    @Override
    public QueryResult<T> queryData(BasicQuery query) {
        Long count = baseMapper.queryCount(query);
        List<T> ts = baseMapper.queryData(query);
        return new QueryResult<>(count,ts);
    }
    @Override
    public void patchDel(List<Long> ids) {
        baseMapper.patchDel(ids);
    }



}
